<!-- ************************************************************************************************************ -->
<!-- fileName          : client_leftguide_display.jsp 															  -->
<!-- summary           : client端  左侧导航  页面显示 																	  -->
<!-- ************************************************************************************************************ -->

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/immigration/css/guide.css" />
<link rel="stylesheet" type="text/css" href="/immigration/css/bootstrap/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/immigration/css/bootstrap/bootstrap-responsive.min.css" />
<link rel="stylesheet" type="text/css" href="/immigration/css/layout.css">
<script type="text/javascript" src="/immigration/js/jquery.js"></script>
<script type="text/javascript" src="/immigration/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/immigration/js/guide.js"></script>
<title>Immigration Explore | 探索移民</title>
<style type="text/css">
.main-connent,.right {
	margin-top: 60px;
}

.content {
	padding: 5px 50px;
	overflow: auto;
}

.main-connent {
	width: 75%;
	float: left;
	font-size: 13px;
	line-height: 14px;
	border-radius: 4px;
	box-shadow: 0 0 10px #ccc;
}

.right {
	width: 23%;
	float: right;
	font-size: 13px;
	line-height: 13px;
	border-radius: 4px;
	box-shadow: 0 0 10px #ccc;
}

.main-connent .main-left {
	width: 76%;
	float: left;
}

.main-connent .main-mid {
	width: 23%;
	float: right;
}

.main-connent .main-left .main-left-top {
	width: 100%;
}

.main-connent .main-left .main-left-bottom {
	width: 100%;
}

.main-left-bottom.main-bottom-left {
	width: 30%;
	float: left;
}

.main-left-bottom.main-bottom-right {
	width: 30%;
	float: right;
}

.main-connent .main-mid  .main-mid-top {
	width: 100%
}

.main-connent .main-mid  .main-mid-bottom {
	width: 100%
}

.title-icon {
	padding: 5px 15px;
	border-bottom: #fff 1px solid;
	color: #000000;
	font-weight: bold;
	font-size: 14px;
}

p {
	display: block;
	-webkit-margin-before: 0px;
	-webkit-margin-after: 0px;
	-webkit-margin-start: 0px;
	-webkit-margin-end: 0px;
	padding: 0 20px;
	margin:0;
}

</style>
</head>
<!--头部start-->
<body>
<%
	//设置请求的字符编码以支持中文
	request.setCharacterEncoding ("utf-8");

	int intPageSize; //一页显示的记录数 
	int intRowCount; //记录总数 
	int intPageCount; //总页数 
	int intPage; //待显示页码 
	String strPage; 
	
	//设置一页显示的记录数 
	intPageSize = 24; 
	
	//取得待显示页码 
	strPage = request.getParameter("page"); 
	if(strPage==null){//表明在QueryString中没有page这一个参数，此时显示第一页数据 
		intPage = 1; 
	}
	else{//将字符串转换成整型 
		intPage = java.lang.Integer.parseInt(strPage); 
		if(intPage< 1){ 
			intPage = 1; 
		} 
	} 
	//获取请求参数
	String currentId = request.getParameter("CId");
	
	//从web.xml获取全局参数
	String drv=config.getServletContext().getInitParameter("DBDriver");
	String url=config.getServletContext().getInitParameter("DBURL");
	String uid=config.getServletContext().getInitParameter("DBUser");
	String pwd=config.getServletContext().getInitParameter("DBPass");
	
	//构建SQL字符串和JDBC对象
	String strSQL5 = "SELECT * FROM immie0_immi.contentlink t WHERE t.id=?";	// (id, name, content_name, content, url, father_id, date)
	String strSQL1 = "SELECT * FROM immie0_immi.leftguide lg WHERE lg.father_id=-1";	// (id, name, content_name, content, url, father_id, date)
	String strSQL2 = "SELECT * FROM immie0_immi.leftguide lg WHERE lg.father_id=?";		// (id, name, content_name, content, url, father_id, date) 
	String strSQL3 = "SELECT * FROM immie0_immi.leftguide lg WHERE lg.father_id=?";   	// (id, name, content_name, content, url, father_id, date)
	String strSQL4 = "SELECT * FROM immie0_immi.rightguide rg WHERE rg.father_id=-1";	// (id, name, content_name, content, url, father_id, date)
	String strSQL6 = "SELECT * FROM immie0_immi.contentlink cl WHERE cl.father_id=-1";	// (id, name, content_name, content, url, father_id, date)
	
	Connection conn = null;
	PreparedStatement pstmt1 = null;
	PreparedStatement pstmt2 = null;
	PreparedStatement pstmt3 = null;
	PreparedStatement pstmt4 = null;
	PreparedStatement pstmt5 = null;
	PreparedStatement pstmt6 = null;
	ResultSet rs5 = null; //要显示的页面id
	ResultSet rs1 = null; //左侧导航父节点
	ResultSet rs2 = null; //左侧导航子节点
	ResultSet rs3 = null; //左侧导航子子节点
	ResultSet rs4 = null; //右侧导航
	ResultSet rs6 = null; //文章标题处常用链接

	try {
		Class.forName(drv).newInstance();
		conn = DriverManager.getConnection(url,uid,pwd);
		pstmt5 = conn.prepareStatement(strSQL5);		
		//设置SQL语句的参数
		pstmt5.setString(1, currentId);	
		rs5 = pstmt5.executeQuery();
		rs5.next();
		
		if( !rs5.getString(4).isEmpty() && rs5.getString(5).equals("NULL")){ //content非空， url=NULL，内部页面		%>
		
	<div>
	<jsp:include page="/page/client/client_top.jsp"></jsp:include>
	</div>	
	
	<div id="mainContent">
		
		<div id="sidebar">
			<div class="pnav-cnt">
<%
			pstmt1 = conn.prepareStatement(strSQL1);		
			
			rs1 = pstmt1.executeQuery();
			
			while(rs1.next()) {
%>
				<div class="pnav-box" id="letter-a">
					<div class="box-title">
						<a class="btn-fold hidden" href="#"></a> 
						<a class="btn-unfold" href="#"></a> 
<% 						if( !rs1.getString(4).isEmpty() && rs1.getString(5).equals("NULL")){ //content非空， url=NULL，内部页面	
%>						<a href="/immigration/page/client/client_leftguide_display.jsp?CId=<%=rs1.getString(1)%>"><span class="pnav-letter" ><%=rs1.getString(2)%></span></a>
<%						}
						if( rs1.getString(4).equals("NULL") && !rs1.getString(5).isEmpty() ){ //content=NULL， url非空，外部链接	
%>						<a href="<%=rs1.getString(5)%>" target="_blank" ><span class="pnav-letter"><%=rs1.getString(2)%></span></a>
<%						}
%>					</div>
					
<%				pstmt2 = conn.prepareStatement(strSQL2);
				//设置SQL语句参数
				pstmt2.setString(1, rs1.getString(1) );
						
				rs2 = pstmt2.executeQuery();
							
				if(rs2.next()) {			%>
								
					<ul class="box-list">
						<li>
							<a class="btn-fold hidden" href="#"></a> 
							<a class="btn-unfold" href="#"></a>
<% 							if( !rs2.getString(4).isEmpty() && rs2.getString(5).equals("NULL")){ //content非空， url=NULL，内部页面	
%>							<b> <a href="/immigration/page/client/client_leftguide_display.jsp?CId=<%=rs2.getString(1)%>" ><%=rs2.getString(2) %></a></b>
<%							}
							if( rs2.getString(4).equals("NULL") && !rs2.getString(5).isEmpty() ){ //content=NULL， url非空，外部链接	
%>							<b> <a href="<%=rs2.getString(5)%>" target="_blank" ><%=rs2.getString(2) %></a></b>
<%							}
%>							<span class="cDGray"> </span>	
<%				
					pstmt3 = conn.prepareStatement(strSQL3);
					//设置SQL语句参数
					pstmt3.setString(1, rs2.getString(1) );
								
					rs3 = pstmt3.executeQuery();
								
					while(rs3.next()) { 		%>
							<p style="margin:0 0 0 0;">
<% 							if( !rs3.getString(4).isEmpty() && rs3.getString(5).equals("NULL")){ //content非空， url=NULL，内部页面	
%>								<a href="/immigration/page/client/client_leftguide_display.jsp?CId=<%=rs3.getString(1)%>" ><%=rs3.getString(2)%></a>
<%							}
							if( rs3.getString(4).equals("NULL") && !rs3.getString(5).isEmpty() ){ //content=NULL， url非空，外部链接	
%>								<a href="<%=rs3.getString(5)%>" target="_blank" ><%=rs3.getString(2) %></a>
<%							}
%>							</p>
<% 					}	//第三个while 结束			%>
						</li>
<% 				}
				while(rs2.next()) { 		%>
						<li><a class="btn-fold hidden" href="#"></a> 
							<a class="btn-unfold" href="#"></a>
<% 							if( !rs2.getString(4).isEmpty() && rs2.getString(5).equals("NULL")){ //content非空， url=NULL，内部页面	
%>							<b> <a href="/immigration/page/client/client_leftguide_display.jsp?CId=<%=rs2.getString(1)%>" ><%=rs2.getString(2) %></a></b>
<%							}
							if( rs2.getString(4).equals("NULL") && !rs2.getString(5).isEmpty() ){ //content=NULL， url非空，外部链接	
%>							<b> <a href="<%=rs2.getString(5)%>" target="_blank" ><%=rs2.getString(2) %></a></b>
<%							}
%>							<span class="cDGray"> </span>											
<%						
					pstmt3 = conn.prepareStatement(strSQL3);
					//设置SQL语句参数
					pstmt3.setString(1, rs2.getString(1) );
							
					rs3 = pstmt3.executeQuery();
							
					while(rs3.next()) { 		%>
							<p style="margin:0 0 0 0;">
<% 							if( !rs3.getString(4).isEmpty() && rs3.getString(5).equals("NULL")){ //content非空， url=NULL，内部页面	
%>								<a href="/immigration/page/client/client_leftguide_display.jsp?CId=<%=rs3.getString(1)%>" ><%=rs3.getString(2)%></a>
<%							}
							if( rs3.getString(4).equals("NULL") && !rs3.getString(5).isEmpty() ){ //content=NULL， url非空，外部链接	
%>								<a href="<%=rs3.getString(5)%>" target="_blank" ><%=rs3.getString(2) %></a>
<%							}
%>							</p>
	<% 				}	//第三个while 结束			%>
						</li>
	<%			}//第二个while 结束					%>
					</ul>
				</div>
<% 			}	//第一个while 结束					%>
			<script type="text/javascript">
				//<![CDATA[ 
					(function() {
						NTES("span.photo-search input[type=text]")
							.addEvent(
								"focus",
								function() {
									this.value == this.defaultValue
											&& (this.value = "");
								})
							.addEvent(
								"blur",
								function() {
									this.value == ""
											&& (this.value = this.defaultValue);
								});
						NTES("div.pnav-box div.box-title a.btn-fold")
							.addEvent(
								"click",
								function(e) {
									e.preventDefault();
									var eleTitle = NTES(this.parentNode);
									NTES(this).addCss("hidden");
									eleTitle.$("a.btn-unfold")
											.removeCss("hidden");
									NTES(eleTitle.parentNode).$(
											"ul.box-list")
											.removeCss("hidden");
								});
						NTES("div.pnav-box div.box-title a.btn-unfold")
							.addEvent(
								"click",
								function(e) {
									e.preventDefault();
									var eleTitle = NTES(this.parentNode);
									NTES(this).addCss("hidden");
									eleTitle.$("a.btn-fold")
											.removeCss("hidden");
									NTES(eleTitle.parentNode).$(
											"ul.box-list").addCss(
											"hidden");
								});
						NTES("div.pnav-box ul.box-list a.btn-fold")
							.addEvent(
								"click",
								function(e) {
									e.preventDefault();
									var eleTitle = NTES(this.parentNode);
									NTES(this).addCss("hidden");
									eleTitle.$("a.btn-unfold")
											.removeCss("hidden");
									eleTitle.$("p").removeCss(
											"hidden");
								});
						NTES("div.pnav-box ul.box-list a.btn-unfold")
							.addEvent(
								"click",
								function(e) {
									e.preventDefault();
									var eleTitle = NTES(this.parentNode);
									NTES(this).addCss("hidden");
									eleTitle.$("a.btn-fold")
											.removeCss("hidden");
									eleTitle.$("p")
											.addCss("hidden");
								});
						new NTES.ui.Slide(NTES("ul.photo-snav li"),
								NTES("div.photo-scnt"), "active",
								"mouseover", 6000);
					})();
					//]]>
				</script>
			</div>
		</div>
	
		<div id="sidebar2">
			<div class="pnav-cnt-sec">
				<div class="pnav-box-sec">
					<div class="box-title-left">
						<span class="pnav-letter">导		 航</span>
					</div>					
<% 
		pstmt4 = conn.prepareStatement(strSQL4);		
						
		rs4 = pstmt4.executeQuery();
		rs4.absolute(1);
		
		//获取记录总数 
		rs4.last(); 
		intRowCount = rs4.getRow(); 

		//记算总页数 
		intPageCount = (intRowCount+intPageSize-1) / intPageSize; 

		//调整待显示的页码 
		if(intPage >intPageCount) intPage = intPageCount; 
			
		if(intPageCount >0){ 
			//将记录指针定位到待显示页的第一条记录上 
			rs4.absolute((intPage-1) * intPageSize+1); 
			//显示数据 
			int i = 0; 				%>
					<ul class="nav nav-pills nav-stacked" style="margin-bottom:0px;">
<%
				while(i< intPageSize && !rs4.isAfterLast()){ 	
					if( !rs4.getString(4).isEmpty() && rs4.getString(5).equals("NULL")){ //content非空， url=NULL，内部页面	
%>						<li><a style="word-break:keep-all;/* 不换行 */white-space:nowrap;/* 不换行 */overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/" href="/immigration/page/client/client_rightguide_display.jsp?CId=<%=rs4.getString(1)%>&page=<%=intPage%>"  ><%=rs4.getString(2)%></a></li>
<%					}
					if( rs4.getString(4).equals("NULL") && !rs4.getString(5).isEmpty() ){ //content=NULL， url非空，外部链接	
%>						<li><a style="word-break:keep-all;/* 不换行 */white-space:nowrap;/* 不换行 */overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/" href="<%=rs4.getString(5) %>"  target="_blank" ><%=rs4.getString(2)%></a></li>
<%					}
					rs4.next(); 
					i++; 
				}rs4.close(); 
				i=0; 

				if(intPage<2){ %> 
						<li><a style="float:left;margin:0;" >上一页</a>
<%				}else{	%> 
						<li><a style="float:left;margin:0;" href="/immigration/page/client/client_contentlink_display.jsp?page=<%=intPage-1%>&CId=<%=rs5.getString(1)%>">上一页</a> 
<%				}
				if((intPageCount-intPage)<1) {	%> 
							<a style="float:right;margin:0;">下一页</a> </li>
<%				}else{%> 
							<a style="float:right;margin:0;" href="/immigration/page/client/client_contentlink_display.jsp?page=<%=intPage+1%>&CId=<%=rs5.getString(1)%>">下一页</a> </li>
<%				} 
			} 
			else{ 
				out.print("<center><table border=0 align=center cellpadding=0 cellspacing=1 ><tr><td><center>目前还没有内容！</center></td></tr></table></centre>"); 
			} 	
%>					</ul>				
				</div>
			</div>
		</div>
	
		<div id="contentlinkcontent" style=" min-height:856px; border-left:#dcdddd 1px solid; border-top:#dcdddd 1px solid; border-right:#dcdddd 1px solid; margin:0 305px 0 187px !important; background-image: url(/immigration/image/client_bg.png);" >
				
			<div id="content-title">
	 			<font><%=rs5.getString(3) %></font>
	 		</div>
					
			<div  id="content-timeline">
	 			<font style="font-family: Microsoft YaHei;	font-size:15px; float:left; ">修改时间：<%=rs5.getDate(7) %></font>
	 			<div style="float:left;">
	 				<font style="font-family: Microsoft YaHei;	font-size:15px;  margin-left:20px;">常用链接：</font>
<% 					
		pstmt6 = conn.prepareStatement(strSQL6);		
							
		rs6 = pstmt6.executeQuery();			
		while(rs6.next()) {						%>
					<a href="/immigration/page/client/client_contentlink_display.jsp?CId=<%=rs6.getString(1) %>" ><%=rs6.getString(2) %></a>
<%		}				%>
	 			</div>
	 		</div>
					
			<div id="content-content"><%=rs5.getString(4) %></div>

		</div>
		<br class="clearfloat" /> 
	</div>
	
	<div>
	<jsp:include page="/page/footer.jsp"></jsp:include>
	</div>
			
<%		}
		if( rs5.getString(4).equals("NULL") && !rs5.getString(5).isEmpty() ){ //content=NULL， url非空，外部链接	 	%>			
		
		<script language="javascript">
		<!-- 
		window.open ("<%=rs5.getString(5) %>","_self");		
		--> 
		</script>
			
<%			}
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	} catch (InstantiationException e) {
	    e.printStackTrace();
	} catch (IllegalAccessException e) {
		e.printStackTrace();
	} catch (SQLException e) {
		e.printStackTrace();
	} 
	finally {
		if (rs1 != null) {
			rs1.close();
			rs1 = null;
		}
		if (rs2 != null) {
			rs2.close();
			rs2 = null;
		}
		if (rs3 != null) {
			rs3.close();
			rs3 = null;
		}
		if (rs4 != null) {
			rs4.close();
			rs4 = null;
		}
		if (rs5 != null) {
			rs5.close();
			rs5 = null;
		}
		if (rs6 != null) {
			rs6.close();
			rs6 = null;
		}
		if (pstmt1 != null) {
			pstmt1.close();
			pstmt1 = null;
		}	
		if (pstmt2 != null) {
			pstmt2.close();
			pstmt2 = null;
		}
		if (pstmt3 != null) {
			pstmt3.close();
			pstmt3 = null;
		}
		if (pstmt4 != null) {
			pstmt4.close();
			pstmt4 = null;
		}
		if (pstmt5 != null) {
			pstmt5.close();
			pstmt5 = null;
		}
		if (pstmt6 != null) {
			pstmt6.close();
			pstmt6 = null;
		}	
		if (conn != null) {
			conn.close();
			conn = null;
		}
	}		%>	

</body>
</html>



